package com.cmc.cloud.cmclink.doc.util.so;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

/**
 * 仅可用于国际化转换
 *
 * @author dev89
 * @date 2025/09/26 13:19
 **/

public class ReadExcelUtil {
    public static void readXlsxFile(String filePath) {
        try (FileInputStream fis = new FileInputStream(new File(filePath));
            XSSFWorkbook workbook = new XSSFWorkbook(fis)) {
            Sheet sheet = workbook.getSheetAt(0);
            List<String> cnList = new ArrayList<>();
            List<String> enList = new ArrayList<>();
            for (Row row : sheet) {
                Cell cell1 = row.getCell(0);
                cell1.setCellType(CellType.STRING);
                Cell cell2 = row.getCell(1);
                cell2.setCellType(CellType.STRING);
                Cell cell3 = row.getCell(2);
                cell3.setCellType(CellType.STRING);
                String cnStr = cell1.getStringCellValue() + "=" + cell2.getStringCellValue();
                String enStr = cell1.getStringCellValue() + "=" + cell3.getStringCellValue();
                cnList.add(cnStr);
                enList.add(enStr);
            }
            cnList.forEach(System.out::println);
            enList.forEach(System.out::println);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        readXlsxFile("E:\\FCN国际化\\工作簿2补充2.xlsx");
    }
}
